package com.sse.util.hashing;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class HashUtil implements IHashUtil{

	@Override
	public String MD5(String cadena) {
		
		String hashtext = null;
		
		try {
			MessageDigest m = MessageDigest.getInstance("MD5");
			m.reset(); 
			m.update(cadena.getBytes()); 
			
			byte[] digest = m.digest(); 
			BigInteger bigInt = new BigInteger(1,digest); 
			
			hashtext = bigInt.toString(32);
			
			
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
		return hashtext;
		
	}

}
